package com.huawei.fastengine.fastview.download.utils;

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;

public final class UiHelper {
    public static final String TAG = "UiHelper";
    private static DisplayMetrics mDisplayMetrics;

    private UiHelper() {
    }

    public static int dp2px(Context context, int i) {
        if (mDisplayMetrics == null) {
            mDisplayMetrics = new DisplayMetrics();
            if (context != null) {
                WindowManager windowManager = (WindowManager) context.getSystemService("window");
                if (!(windowManager == null || windowManager.getDefaultDisplay() == null)) {
                    windowManager.getDefaultDisplay().getMetrics(mDisplayMetrics);
                }
            }
        }
        return (int) (((float) i) * mDisplayMetrics.density);
    }
}
